//转化省标数据内容
var pageii = null;
var baseURL = "../../";
$(function () {
	selfAdaptionScreen();
    /*$('.auditIssues').click(function () {
        auditIssues()
    })
    $('.reviewAndRectify').click(function () {
        reviewAndRectify()
    })*/
    $('.dtTab li').click(function () {
        $(this).siblings().removeClass('selected')
        $(this).addClass('selected')
//        var val = $(this).attr("data-id")
//        var selectDateId = $(this).attr('id');
//        switch (selectDateId) {
//        
//            //已审核
//            case 'audited' :
//                layer.msg("已审核"+val)
//                break
//            //未审核
//            case 'unaudited' :
//                layer.msg("未审核"+val)
//                break
//            //已整改
//            case 'haveChanged' :
//                layer.msg("已整改"+val)
//                break
//            //未整改
//            case 'noChanged' :
//                layer.msg("未整改"+val)
//                this.getQuestionDetail();
//                break
//            //全部
//            default:
//                layer.msg("全部"+val)
//        }
    });

})
//自适应屏幕分辨率
function selfAdaptionScreen(){
	var screenWidth = window.screen.width;
	if(screenWidth<=1366){
		$("#dcjlBody").css("zoom","0.62");
	}else if(screenWidth>1366 && screenWidth<=1440){
		$("#dcjlBody").css("zoom","0.64");
	}else if(screenWidth>1440 && screenWidth<=1600){
		$("#dcjlBody").css("zoom","0.72");
	}else if(screenWidth>1600 && screenWidth<=1680){
		$("#dcjlBody").css("zoom","0.78");
	}else if(screenWidth>1680 && screenWidth<=1768){
		$("#dcjlBody").css("zoom","0.82");
	}else{
		$("#dcjlBody").css("zoom","0.91");
	}
}
function auditIssues(id) {
    pageii = layer.open({
        title: "审核",
        type: 2,
        shadeClose: true,
        fixed: true,
        area: ["850px", "550px"],
        content: baseURL + '/business/record/auditIssues.html'
    });
}
function reviewAndRectify(id) {
    pageii = layer.open({
        title: "整改",
        type: 2,
        shadeClose: true,
        fixed: true,
        area: ["850px", "550px"],
        content: baseURL + '/business/record/reviewAndRectify.html'
    });
}
var options={
		fullscreenEl:false //关闭全屏按钮
	}

Vue.use(vuePhotoPreview,options)
var vm = new Vue({
    el: '#rrapp',
    data: {
    	
        id:'',
        showList: true,
        title: null,
        firstAddShowFlag: true,
        addFirstKindDetailData: {},
        superviseRecordData:{},
        questionData:{},
        roleId:$("#roleId").val(),
        dqDwId:$("#dqDwId").val(),
        firstKindSubmitForm: {
            levelNum: '1',
            questionDescription: '',
            isGenerateStandardTemplate: '0',
            parentId: '0'
        }
    },
    mounted () {
        this.getDataDetail();
        this.getQuestionDetail();
        setTimeout(() => {
            vm.$previewRefresh()
        }, 2000);
    },

    methods: {
    	
    	getDataDetail: function() {
    		//debugger;
    		//let id = this.$route.query.id;
    		//vm.id:,
    		let params = {
                id:$("#id").val()
            }
//    		debugger;
    		let url = baseURL;
    		url = url +'business/superviserecord/detailInfo';
    		$.ajax({
                type: "GET",
                url: url,
                data:params,
                contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {
//                    	debugger;
                        vm.superviseRecordData = res.superviseRecord;
                        
                    } else {
                        alert(res.msg);
                    }
                }
            });
    	},
    	 TabHandleClick(tab) {
    	   alert(tab.name)
    	 },
    	 findQuestionList: function(type) {
    	   vm.getQuestionDetail(type)
    	 },
    	getQuestionDetail: function(type) {//全部 未整改 无整改 已整改 未审核 已审核
            setTimeout(() => {
                vm.$previewRefresh()
            }, 2000);
    		let modifyStatus = '';//整改状态(0：待整改，1：无整改，2：已整改，3：备存无整改，4：备存待整改)
    		let checkStatus = ''; //审核状态(0：待审核，1：审核通过，2：审核未通过)
    		if (type === 2) {
    			modifyStatus = '0';
    		} else if (type === 3) {
                modifyStatus = '1';
            }else if (type === 4) {
    			modifyStatus = '2';
    		} else if (type === 5) {
    			checkStatus = '0';
    		} else if (type === 6) {
    			checkStatus = '1';
    		}
    		let params = {
    			dcRecordId: $("#id").val(),
    			modifyStatus: modifyStatus,
    			checkStatus: checkStatus
            }
    		//debugger;
    		let url = baseURL;
    		url = url +'business/supervisequestion/questionDetailInfo';
    		$.ajax({
                type: "GET",
                url: url,
                data:params,
                contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {debugger;
                    	//debugger;
                        vm.questionData = res.questionList;
                        for (let i=0; i < res.questionList.length; i++) {
                            let imageList = res.questionList[i].imageList;
                            let fkImageList = res.questionList[i].fkImageList;
                            var rootPath = $("#rootPath").val();
                            let videUrl = res.questionList[i].videoImage;
                            if (videUrl != undefined && videUrl != null && videUrl != '') {
                            	res.questionList[i].videoImage = rootPath + encodeURI(videUrl);
                            }
                            if (imageList != undefined && imageList != null && imageList != '') {
                            	 for (let j=0; j<imageList.length; j++) {
                                     let picUrl = imageList[j].picUrl;
                                     imageList[j].picUrl = rootPath + encodeURI(picUrl);
                                 }
                            }
                           
                            if (fkImageList != undefined && fkImageList != null && fkImageList != '') {
	                            for (let k=0; k<fkImageList.length; k++) {
	                                let picUrl = fkImageList[k].picUrl;
	                                fkImageList[k].picUrl = rootPath + encodeURI(picUrl);
	                            }
                            }
                        }
                        /*$("#contentDetail").css("height",res.questionList.length*480+"px");*/
                    } else {
                        alert(res.msg);
                    }
                }
            });
    	},
    	//type=1 
    	checkQuestion (type, questionId, recordId, questionModifyId, questionDescription) {
    		//let questionId = $("#id").val();
    		//let recordId = recordId;
    		//let questionModifyId = questionModifyId;
    		//debugger;
    		let url = '/business/supervise/questionOpen?questionId='+questionId + "&recordId=" +recordId + "&questionModifyId=" +questionModifyId + "&questionDescription=" +questionDescription + "&type=" +type;
            layer.open({
                title : "",
                type : 2,
                fixed: true,
                shadeClose: true,
                area : [ "800px", "80%" ],
                content : baseURL + encodeURI(url)
            });
    	},
    	playVideo (videoUrl){
    	    layer.open({
                //title : "新增执行记录",
                type : 2,
                fixed: true,
                shadeClose: true,
                area : [ "600px", "400px" ],
                content : baseURL + '/business/supervise/openVideo?url='+ encodeURI(videoUrl)
            });
    	},

    	closeWindow: function() {
    		parent.location.reload();
    	},
        //取消
        cancelFirstAdd: function () {

        },
    }

});